package com.mccken.designpattern.create_type.singleton;

import java.util.concurrent.atomic.AtomicLong;

/**
 * @program: mccken-collect
 * @description:
 * @author: mccken
 * @create: 2024-03-11 12:07
 **/
public class IdGenerator2 {
	
	private AtomicLong id = new AtomicLong(0);
	private static IdGenerator2 instance;
	private IdGenerator2(){}
	public static IdGenerator2 getInstance() {
		if (instance == null) {
			synchronized(IdGenerator2.class) {
				if (instance == null) {
					instance = new IdGenerator2();
				}
			}
		}
		
		return instance;
	}
	
}
